using System;
using System.Collections.Generic;
using System.IO;

using Clandestine.Audio;

namespace nicotine
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string filename = "addandmenu.nico";
			
			if (args.Length > 0)
			{
				Console.WriteLine("Alright, trying to load `" + args[0] + "'...");
				filename = args[0];
			}
			else
				Console.WriteLine("Trying to load " + filename + ".nico...");
			
			if (!File.Exists(filename))
				Console.WriteLine("Er, failure. The file doesn't exist.  (Perhaps you're on a case-sensitive filesystem, and the casing is wrong?)");
			else
			{
				// Read whole file in.  Dammit, why can't I do this in one line?  Very tedious.
				List<string> cakes = new List<string>();
				StreamReader sr = File.OpenText(filename);
				
				while (!sr.EndOfStream)
					cakes.Add(sr.ReadLine());
				
				new Interpreter(cakes, new Audio()).Run();
			}
		}
	}
}
